/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.managerServer.executors;

import protocol.Executor;
import protocol.*;
import server.Poll;
import server.managerServer.ServerWorker;
import protocol.ThreadWorker;

/**
 *
 * @author radu
 */
public class ExecutorCreatePoll extends Executor {

    MessageCreatePollReq msg;

    public ExecutorCreatePoll(Message _msg) {
        super(_msg);
        msg = (MessageCreatePollReq) _msg;
    }

    @Override
    public void doWork(ThreadWorker worker) {
        ServerWorker serverWorker = (ServerWorker) worker;

        String options[] = msg.getOptionList();
        long pollId = serverWorker.createPoll(options, serverWorker.getAdminEmail());
        Message msg = new MessageCreatePollRep(pollId);
        
        serverWorker.sendMessage(msg);
    }
}
